package com.homedo.async.mysql.support.mapper.insert;

import com.homedo.async.mysql.support.mapper.MapperI;
import io.vertx.sqlclient.SqlConnection;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author jgshun
 * @date 2020/3/17 10:30 AM
 */
public interface SaveMapperI<T, ID> extends MapperI<T, ID> {

    <S extends T> Mono<S> saveSelective(S entity);

    <S extends T> Flux<S> saveSelective(Iterable<S> entities);

    <S extends T> Flux<S> saveSelective(Publisher<S> entityStream);

    <S extends T> Mono<S> save(S entity);

    <S extends T> Flux<S> save(Iterable<S> entities);

    <S extends T> Flux<S> save(Publisher<S> entityStream);

//=== 传入 Connection 是为了统一获得事务能力

    <S extends T> Mono<S> saveSelective(S entity, SqlConnection connection);

    <S extends T> Flux<S> saveSelective(Iterable<S> entities, SqlConnection connection);

    <S extends T> Flux<S> saveSelective(Publisher<S> entityStream, SqlConnection connection);

    <S extends T> Mono<S> save(S entity, SqlConnection connection);

    <S extends T> Flux<S> save(Iterable<S> entities, SqlConnection connection);

    <S extends T> Flux<S> save(Publisher<S> entityStream, SqlConnection connection);

}
